<template>
    <div>
        <el-card class="box-card" id="fullscreen">
            <div class="app-container">
                <div class="container-header">
                    <div class="hign-line" style="float:left"></div>
                    <div class="header-left" style="float:left">
                        {{$t('inventoryManagement.inspectionInfo')}}
                    </div>
                    <div class="header-right" style="float:right">
                        <i class="s-icon" :class="{
            'el-icon-full-screen': !fullscreen,
            'el-icon-copy-document': fullscreen,
          }" @click="changeFull"></i>
                    </div>
                </div>
                <el-row :gutter="10" class="mb8" v-if="!isView&&!disabled">
                    <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd">{{$t('public.add')}}</el-button>
                    <el-button type="primary" v-if="isTemplate" icon="el-icon-search" size="mini" @click="handleSelectTemplate">{{$t('inspectionManagement.selectTemplate')}}</el-button>
                    <el-button type="primary" v-if="isInventory" icon="el-icon-search" size="mini" @click="$emit('copyVisible')">{{$t('inspectionManagement.selectCopy')}}</el-button>
                </el-row>
                <!--  新增或编辑 :height="tableHeight" -->
                <div class="container-table" v-if="!isView&&!disabled">
                    <el-form ref="formTable" :rules="rulesForm" :model="formTable">
                        <el-table v-loading="loading" :data="formTable.extraList" :row-class-name="tableRowClassName"
                         @selection-change="handleSelectionChange" >
                            <el-table-column type="selection" width="55" align="center" />
                          <el-table-column :label="$t('public.opera')" align="center" width="150">
                            <template slot-scope="scope">
                              <div class="action-wrap">

                                <el-button type="primary" icon="el-icon-sort-down " circle :disabled="scope.$index >= formTable.extraList.length-1"  @click.native="downRow(scope,scope.$index)" class="btn" size="mini"></el-button>
                                <el-button  type="primary" icon="el-icon-sort-up" circle :disabled="scope.$index < 1"   @click.native="upRow(scope,scope.$index)" class="btn" size="mini"></el-button>
                                <table-body-btn type="delete" @click.native="handleDelete(scope)" style="margin-left: 10px;"/>
                              </div>
                            </template>
                          </el-table-column>
                            <el-table-column type="index" :label="$t('inventoryManagement.index')"></el-table-column>
                            <el-table-column :label="$t('inventoryManagement.specialCharacteristics')" align="left" prop="symbol" width="120" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.symbol'">

                                        <el-select v-model="scope.row.symbol" :popper-append-to-body="fullscreen?false:true" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option key="空" label="空" value="空" />
                                            <el-option style="font-size:22px" size="mini" v-for="item in specialCharacteristicsOptions" :key="item.value" :label="item.label" :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                             <!-- 检验项目类型 新增 检验项目选择时带出 -->
                            <el-table-column :label="$t('basicData.projectType')" align="left" prop="projectType" width="100" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item>
                                        <el-input disabled v-model="scope.row.projectType" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.inspectionItems')" :render-header="remarkRenderHeader" align="left" prop="inspectionItems" min-width="220">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.projectName'" :rules="projectNameRules(scope.row,scope.$index)">
                                        <el-autocomplete style="width:100%" size="small" popper-class="my-autocomplete" placeholder="请输入内容"
                                            @blur="(e)=>projectBlur(e,scope.row,scope.$index)"
                                            :popper-append-to-body="fullscreen?false:true"
                                            v-model="scope.row.projectName"
                                            :fetch-suggestions="(e,cb)=>projectRemoteMethod(e,cb,scope.$index)"
                                            @select="(e)=>handleProjectSelect(e,scope)">
                                            <i class="el-icon-search el-input__icon" slot="suffix"></i>
                                            <template slot-scope="{ item }">
                                                {{ item.projectName }}
                                            </template>
                                        </el-autocomplete>
                                        <!-- <el-select v-model="scope.row.projectName" :placeholder="$t('public.selectPl')" clearable filterable @change="changeProject(scope)" size="mini">
                                            <el-option size="mini" v-for="item in projectList" :key="item.projectCode" :label="item.projectName" :value="item.projectName">
                                            </el-option>
                                        </el-select> -->
                                        <!-- <project-dialog :disabled="isView" v-model="scope.row.projectName" @callback="(row)=>projectDataCallback(row,scope)" /> -->
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.code')" align="left" prop="projectCode" width="100" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item>
                                        <el-input disabled v-model="scope.row.projectCode" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.inspectionType')" :render-header="remarkRenderHeader" width="110" align="left" prop="checkoutTypeCopy">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.checkoutTypeCopy'" :rules="checkoutTypeRules(scope.row,scope.$index)">
                                        <el-select :popper-append-to-body="fullscreen?false:true" :disabled="scope.row.detectionOne==='核对COA'" v-model="scope.row.checkoutTypeCopy" filterable :placeholder="$t('public.selectPl')" size="mini" @change="checkoutTypeChange(scope.row)">
                                            <el-option size="mini" v-for="(item,index) in dict.type.NYIQC_CHECK_TYPE" :key="index" :label="item.label" :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.targetValue')" align="center" prop="targetValue" min-width="180" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item class="textarea-change" :prop="'extraList.' + scope.$index + '.targetValue'">
                                        <!-- <el-input v-model="scope.row.targetValue" clearable size="small" /> -->
                                        <el-input v-model="scope.row.targetValue" resize="none" @input="(e)=>textAreaChange(e,scope.$index)" clearable size="small" type="textarea" :rows="scope.row.targetValue?scope.row.rows:1" />
                                    </el-form-item>
                                    <!-- <el-form-item v-if="scope.row.checkoutType === '数值'" :prop="'extraList.' + scope.$index + '.targetValue'" :rules="targetValueRules(scope.row,scope.$index)">
                                        <el-select v-model="scope.row.targetValue" size="mini">
                                            <el-option size="mini" label="OK" value="OK"></el-option>
                                            <el-option size="mini" label="NG" value="NG"></el-option>
                                        </el-select>
                                    </el-form-item> -->
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inspectionManagement.lowerTolerance')" align="center" prop="lwTolerance" width="100" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item v-if="scope.row.checkoutType!='布尔型'" :prop="'extraList.' + scope.$index + '.lwTolerance'">
                                        <el-input type="number" min=0 v-model="scope.row.lwTolerance" @input="(e)=>lwChange(e,scope.$index)" style="width:100%" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inspectionManagement.upperTolerance')" width="100" align="center" prop="upTolerance">
                                <template slot-scope="scope">
                                    <el-form-item v-if="scope.row.checkoutType!='布尔型'">
                                        <el-input type="number" min=0 v-model="scope.row.upTolerance" @input="(e)=>upChange(e,scope.$index)" style="width:100%" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <!-- 是否包含下限值 -->
                            <el-table-column label="是否包含下限值"   width="110" align="left" prop="lowerLimitContains" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.lowerLimitContains'" v-if="scope.row.checkoutType!='布尔型'">
                                        <el-select  v-model="scope.row.lowerLimitContains" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option size="mini" label="包含" value="1"></el-option>
                                            <el-option size="mini" label="不包含" value="0"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.lowerValue')" align="center" prop="lowerLimit" width="100" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item v-if="scope.row.checkoutType!='布尔型'" :prop="'extraList.' + scope.$index + '.lowerLimit'" :rules="lowerLimitRules(scope.row,scope.$index)">
                                        <el-input type="number" min=0 v-model="scope.row.lowerLimit" style="width:100%" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.upperValue')" width="100" align="center" prop="upperLimit">
                                <template slot-scope="scope">
                                    <el-form-item v-if="scope.row.checkoutType!='布尔型'">
                                        <el-input type="number" min=0 v-model="scope.row.upperLimit" style="width:100%" size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <!-- 是否包含上限值 -->
                            <el-table-column label="是否包含上限值"   width="110" align="left" prop="upperLimitContains" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.upperLimitContains'" v-if="scope.row.checkoutType!='布尔型'">
                                        <el-select  v-model="scope.row.upperLimitContains" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option size="mini" label="包含" value="1"></el-option>
                                            <el-option size="mini" label="不包含" value="0"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.decimalPlaces')" :render-header="remarkRenderHeader" width="100" align="left" prop="decimalPlace" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item v-if="scope.row.checkoutType!='布尔型'" :prop="'extraList.' + scope.$index + '.decimalPlace'" :rules="decimalPlaceRules(scope.row,scope.$index)">
                                        <el-input v-model="scope.row.decimalPlace" type="number" min=0 clearable size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.inspectionTypeUnit')" width="120" align="left" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.unitName'">
                                        <el-autocomplete :popper-append-to-body="fullscreen?false:true" style="width:100%" size="small" popper-class="my-autocomplete" v-model="scope.row.unitName" :fetch-suggestions="unitRemoteMethod" placeholder="请输入" @select="(e)=>handleUnitSelect(e,scope)">
                                            <i class="el-icon-search el-input__icon" slot="suffix">
                                            </i>
                                            <template slot-scope="{ item }">
                                                {{ item.unitName }}
                                            </template>
                                        </el-autocomplete>
                                        <!-- <el-select v-model="scope.row.unitName" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option size="mini" v-for="item in unitList" :key="item.unitName" :label="item.unitName" :value="item.unitName">
                                            </el-option>
                                        </el-select> -->
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inspectionManagement.aroundFrequency')" :render-header="remarkRenderHeader" width="100" align="left" prop="itemFrequency" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.itemFrequency'" :rules="itemFrequencyRules(scope.row,scope.$index)">
                                        <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.itemFrequency" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option size="mini" v-for="item in frequencyOptions" :key="item.value" :label="item.label" :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.frequencyValue')" :render-header="remarkRenderHeader" width="100" align="left" prop="itemFrequencyValue" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.itemFrequencyValue'" :rules="itemFrequencyValueRules(scope.row,scope.$index)">
                                        <el-input v-model="scope.row.itemFrequencyValue" clearable size="small" />
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.samplingScheme')" :render-header="remarkRenderHeader" align="left" prop="samplingOne" width="140" :show-overflow-tooltip="true">
                                <template slot-scope="scope">
                                    <el-form-item :prop="'extraList.' + scope.$index + '.samplingOne'" :rules="samplingOneRules(scope.row,scope.$index)">
                                        <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingOne" @change="(e)=>changeSampling(e,scope)" filterable :placeholder="$t('public.selectPl')" size="mini">
                                            <el-option size="mini" v-for="item in samplingSchemeOptions" :key="item.value" :label="item.label" :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.samplingOptions')" :render-header="remarkRenderHeader" align="left" prop="samplingOptions" min-width="180">
                                <template slot-scope="scope">
                                    <el-row>
                                        <el-col :span="12" v-if="scope.row.samplingOne =='GB/T2828.1-2012'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingTwo'" :rules="samplingTwoRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingTwo" filterable:placeholder="$t('public.selectPl')" size="mini">
                                                    <el-option size="mini" v-for="item in dict.type.NYIQC_CE_CLASS" :key="item.value" :label="item.label" :value="item.value">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12" v-if="scope.row.samplingOne =='GB/T2828.1-2012'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingThree'" :rules="samplingThreeRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingThree" filterable :placeholder="$t('public.selectPl')" size="mini">
                                                    <el-option size="mini" v-for="item in dict.type.NYIQC_CE_GB2828" :key="item.value" :label="item.label" :value="item.value">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12" v-if="scope.row.samplingOne =='GB/T2828.2-2008'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingTwo'" :rules="samplingTwoRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingTwo" filterable:placeholder="$t('public.selectPl')" size="mini">
                                                    <el-option size="mini" v-for="item in dict.type.NYIQC_CE_CLASS" :key="item.value" :label="item.label" :value="item.value">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12" v-if="scope.row.samplingOne =='GB/T2828.2-2008'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingThree'" :rules="samplingThreeRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingThree" filterable :placeholder="$t('public.selectPl')" size="mini">
                                                    <el-option size="mini" v-for="item in dict.type.NYIQC_CE_GB2828_2008" :key="item.value" :label="item.label" :value="item.value">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>

                                        <el-col :span="24" v-if="scope.row.samplingOne=='C=0'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingThree'" :rules="samplingThreeRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.samplingThree" filterable size="mini">
                                                    <el-option size="mini" v-for="(item,index) in dict.type.NYIQC_CE_C" :key="index" :label="item.label" :value="item.value">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="24" v-if="scope.row.samplingOne=='百分比'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingTwo'" :rules="samplingTwoRules(scope.row,scope.$index)">
                                                <el-input placeholder="百分比" @mousewheel.native.prevent v-enterNumber min="0" style="width:85%" type="number" size="mini" v-model="scope.row.samplingTwo">
                                                </el-input>
                                                <span v-if="scope.row.samplingOne=='百分比'" style="margin-left:3px">%</span>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="24" v-if="scope.row.samplingOne=='固定抽样'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.samplingTwo'" :rules="samplingTwoRules(scope.row,scope.$index)">
                                                <el-input-number size="small" v-model="scope.row.samplingTwo" controls-position="right" :min="0"></el-input-number>
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </template>
                            </el-table-column>
                          <el-table-column :label="$t('inventoryManagement.defectLevel')" :render-header="remarkRenderHeader" align="left"  width="140" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                              <el-form-item :prop="'extraList.' + scope.$index + '.flawLevel'">
                                <el-select :popper-append-to-body="fullscreen?false:true" v-model="scope.row.flawLevel" @change="(e)=>changeSampling(e,scope)" filterable clearable :placeholder="$t('public.selectPl')" size="mini" :disabled="scope.row.samplingOne !=='GB/T2828.1-2012'">
                                  <el-option size="mini" v-for="item in dict.type.NYIQC_DEFECT_LEVEL" :key="item.value" :label="item.label" :value="item.value">
                                  </el-option>
                                </el-select>
                              </el-form-item>
                            </template>
                          </el-table-column>
                            <el-table-column :label="$t('inventoryManagement.testMethod')" :render-header="remarkRenderHeader" align="left" prop="detectionOne" min-width="180">
                                <template slot-scope="scope">
                                    <el-row>
                                        <el-col :span="scope.row.detectionOne == '量具'?12:24">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.detectionOne'" :rules="detectionOneRules(scope.row,scope.$index)">
                                                <el-select :popper-append-to-body="fullscreen?false:true" @change="(e)=>changeTestMethod(e,scope.row,scope.$index)" v-model="scope.row.detectionOne" filterable :placeholder="$t('public.selectPl')" size="mini">
                                                    <el-option size="mini" v-for="item in testMethodOptions" :key="item.value" :label="item.label" :value="item.value">
                                                    </el-option>
                                                    <el-option size="mini" v-for="item in dict.type.NYIQC_ITEM_DETECTIONONE" :key="item.value" :label="item.label" :value="item.label">
                                                    </el-option>
                                                </el-select>
                                            </el-form-item>
                                        </el-col>
                                        <el-col :span="12" v-if="scope.row.detectionOne == '量具'">
                                            <el-form-item :prop="'extraList.' + scope.$index + '.detectionTwo'"  >
                                                <measuring-tool-dialog style="width:100%" @callback="(row)=>mToolCallback(row,scope)"   :multiple="true" v-model="scope.row.detectionTwo" />
                                            </el-form-item>
                                        </el-col>
                                    </el-row>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form>
                </div>
                <!-- 查看 -->
                <div class="container-table" v-else>
                    <el-table v-loading="loading" :data="formTable.extraList" :height="tableHeight" :row-class-name="tableRowClassName" @selection-change="handleSelectionChange">
                        <!-- <el-table-column type="selection" width="55" align="center" /> -->
                        <el-table-column type="index" :label="$t('inventoryManagement.index')"></el-table-column>
                        <el-table-column :label="$t('inventoryManagement.specialCharacteristics')" align="left" minWidth="110" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{scope.row.symbol}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('basicData.projectType')" align="left" prop="projectType" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.inspectionItems')" align="left" prop="projectName" minWidth="160" />
                        <el-table-column :label="$t('inventoryManagement.code')" align="left" prop="projectCode" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.inspectionTypeUnit')" minWidth="130" prop="unitName" align="left" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.inspectionType')" minWidth="130" align="left">
                            <template slot-scope="scope">
                                <span v-if="!!scope.row.checkoutTypeCopy">{{scope.row.checkoutTypeCopy}}</span>
                                <span v-else>{{scope.row.checkoutType}}</span>
                            </template>
                        </el-table-column>
                        <!-- 移除小数位 -->
                        <!-- <el-table-column :label="$t('inventoryManagement.decimalPlaces')" align="left" prop="decimalPlace" :show-overflow-tooltip="true" /> -->
                        <el-table-column :label="$t('inventoryManagement.frequency')" minWidth="110" align="left" prop="itemFrequency" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.frequencyValue')" align="left" prop="itemFrequencyValue" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.targetValue')" align="left" prop="targetValue" min-width="180" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <el-input v-model="scope.row.targetValue" class="view-textarea" readonly resize="none" @input="(e)=>textAreaChange(e,scope.$index)" clearable size="small" type="textarea" :rows="scope.row.targetValue?scope.row.rows:1" />
                            </template>
                        </el-table-column>
                        <!-- 是否包含上限值 -->
                        <el-table-column label="是否包含上限值" align="left" prop="upperLimitContains" min-width="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                 <span>{{ scope.row.upperLimitContains==='0'?"不包含":"包含" }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.lowerValue')" align="center" prop="lowerLimit" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.upperValue')" align="center" prop="upperLimit" />
                        <!-- 是否包含下限值 -->
                        <el-table-column label="是否包含下限值" align="left" prop="lowerLimitContains" min-width="120" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{ scope.row.lowerLimitContains==='0'?"不包含":"包含" }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.samplingScheme')" align="left" prop="samplingOne" minWidth="140" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.samplingOptions')" align="left" prop="samplingTwo" minWidth="200">
                            <template slot-scope="scope">
                                <template v-if="scope.row.samplingOne == 'GB/T2828.1-2012' || scope.row.samplingOne == 'GB/T2828.1-2008'">
                                <span >{{formatCE_CLASS(scope.row.samplingTwo)}}</span> <span>{{scope.row.samplingThree}}</span>
                                </template>
                                <span v-else-if="scope.row.samplingOne == '百分比'">{{scope.row.samplingTwo}}%</span>
                                <span v-else>{{scope.row.samplingTwo}}</span>
                            </template>
                        </el-table-column>
                        <el-table-column :label="$t('inventoryManagement.defectLevel')" align="left" prop="flawLevel" minWidth="140" :show-overflow-tooltip="true" />
                        <el-table-column :label="$t('inventoryManagement.testMethod')" align="left" prop="detectionOne" :minWidth="200" :show-overflow-tooltip="true">
                            <template slot-scope="scope">
                                <span>{{scope.row.detectionOne}}</span> <span>{{scope.row.detectionTwo}}</span> <span>{{scope.row.measuringCode}}</span>
                            </template>
                        </el-table-column>
                        <!-- <el-table-column label="GAP" align="left" prop="gap" width="80" v-if="!isInventory" /> -->
                        <el-table-column :label="$t('public.opera')" fixed="right" align="center" width="100" v-if="deleteable">
                            <template slot-scope="scope">
                                <div class="action-wrap">
                                    <!-- <table-body-btn type="gwdelete" name="删除" @click.native="handleViewDelete(scope)" /> -->
                                    <el-button type="danger" plain icon="el-icon-delete"  @click.native="handleViewDelete(scope)" />
                                </div>
                            </template>
                        </el-table-column>
                    </el-table>

                </div>
            </div>

            <template-dialog :visible.sync="templateVisible" @callback="(data)=>templateDataCallback(data)" />
        </el-card>
    </div>

</template>

<script>
import {listProject} from '@/api/basic/project'
import {listCheckoutUnit} from '@/api/basic/checkoutUnit'
import {getExtraInfo} from '@/api/inventoryManagement/inspectedInventory'
import MeasuringToolDialog from '@/views/components/MeasuringToolDialog'
import TemplateDialog from '@/views/components/TemplateDialog'
import ProjectDialog from '@/views/components/ProjectDialog'

export default {
    name: 'inspectionItemData',
    dicts: [
        'NYIQC_ITEM_DETECTIONONE', //检测方法
        'NYIQC_CE_CLASS',
        'NYIQC_CE_GB2828',
        'NYIQC_CE_C',
        // 'NYIQC_GAUGE_TYPE',
        'NYIQC_CHECK_TYPE', //ny-iqc-检验类型
        'NYIQC_CE_GB2828_2008',
        // 'NYIQC_PROJECT_TYPE',
        'NYIQC_DEFECT_LEVEL',
    ],
    props: ['itemData', 'disabled', 'isRecheck', 'isInventory','loadings','deleteable'],
    components: {
        MeasuringToolDialog,
        TemplateDialog,
        ProjectDialog
    },
    data() {
        return {
            direction: 'rtl',
            addInspectionExemption: false,
            code: 'EW',
            id: this.$route.params.id || null,
            drawer: false,
            isTemplate: this.$route.query.isTemplate ? true : false,
            approvalOpen: false,
            viewInspectionExemption: false,
            extraList: {
                samplingOne: null,
                samplingTwo: null,
                samplingThree: null,
                measuringTool: null,
                inspectionType: '1',
                lowerLimit: null,
                upperLimit: null,
                projectName: null,
                specialCharacteristics: '0',
                projectCode: null,
                projectType: null,
                itemFrequency: '批',
                itemFrequencyValue: null,
                lowerLimitContains:"1",
                upperLimitContains:"1"
            },
            formTable: {
                extraList: [],
            },
            projectList: [],
            frequencyOptions: [
                {
                    value: '批',
                    label: '批',
                },
                {
                    value: '件',
                    label: '件',
                },
                {
                    value: '年',
                    label: '年',
                },
                {
                    value: '季',
                    label: '季',
                },
                {
                    value: '月',
                    label: '月',
                },
                {
                    value: '周',
                    label: '周',
                },
                {
                    value: '日',
                    label: '日',
                },
            ],
            samplingSchemeOptions: [
                {
                    value: 'GB/T2828.1-2012',
                    label: 'GB/T2828.1-2012',
                },
                {
                    value: '百分比',
                    label: '百分比',
                },
                {
                    value: '固定抽样',
                    label: '固定抽样',
                },
                {
                    value: 'C=0',
                    label: 'C=0',
                },
            ],
            testMethodOptions: [
                {
                    value: '量具',
                    label: '量具',
                },
            ],
            samplingLevelOptions: [
                {
                    value: 'S-1',
                    label: 'S-1',
                },
                {
                    value: 'S-2',
                    label: 'S-2',
                },
                {
                    value: 'S-3',
                    label: 'S-3',
                },
                {
                    value: 'S-4',
                    label: 'S-4',
                },
                {
                    value: 'Ⅰ',
                    label: 'Ⅰ',
                },
                {
                    value: 'Ⅱ',
                    label: 'Ⅱ',
                },
                {
                    value: 'Ⅲ',
                    label: 'Ⅲ',
                },
            ],
            samplingMethodCOptions: [
                {
                    value: '0.01',
                    label: '0.01',
                },
                {
                    value: '0.015',
                    label: '0.015',
                },
                {
                    value: '0.025',
                    label: '0.025',
                },
                {
                    value: '0.04',
                    label: '0.04',
                },
                {
                    value: '0.1',
                    label: '0.1',
                },
                {
                    value: '0.15',
                    label: '0.15',
                },
                {
                    value: '0.25',
                    label: '0.25',
                },
                {
                    value: '0.4',
                    label: '0.4',
                },
                {
                    value: '0.65',
                    label: '0.65',
                },
                {
                    value: '1',
                    label: '1',
                },
                {
                    value: '1.5',
                    label: '1.5',
                },
                {
                    value: '4',
                    label: '4',
                },
                {
                    value: '6.5',
                    label: '6.5',
                },
                {
                    value: '10',
                    label: '10',
                },
            ],
            samplingLevelTypeOptions: [
                {
                    value: '正常',
                    label: '正常',
                },
                {
                    value: '放宽',
                    label: '放宽',
                },
                {
                    value: '加严',
                    label: '加严',
                },
            ],
            samplingFixedTypeOptions: [
                {
                    value: '批',
                    label: '批',
                },
                {
                    value: '件',
                    label: '件',
                },
            ],
            specialCharacteristicsOptions: [
                {
                    value: '○',
                    label: '○',
                },
                {
                    value: '◆',
                    label: '◆',
                },
                {
                    value: '★',
                    label: '★',
                },
            ],
            addModel: {},
            viewModel: {},
            editModel: {},
            approvalForm: {
                status: '1',
                textarea: '',
            },
            isView: this.$route.query.isView ? true : false,
            unitList: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                noticeTitle: undefined,
                noticeType: undefined,
                hasRead: undefined,
                createTime: undefined,
            },
            // 表单参数
            form: {},
            materialOptions: [],
            // 表单校验
            rules: {
                materialName: [
                    {
                        required: true,
                        message: this.$t('formValidation.materialNameCannotBeEmpty'),
                        trigger: 'blur',
                    },
                ],
                materialCode: [
                    {
                        required: true,
                        message: '物料编号不能为空',
                        trigger: 'blur',
                    },
                ],
                materialType: [
                    {
                        required: true,
                        message: '物料类型不能为空',
                        trigger: 'change',
                    },
                ],
                lot: [
                    {
                        required: true,
                        message: '批次不能为空',
                        trigger: 'blur',
                    },
                ],
                batchAmount: [
                    {
                        required: true,
                        message: '来料数量不能为空',
                        trigger: ['blur', 'change'],
                    },
                ],
                mengeneinh: [
                    {
                        required: true,
                        message: '请选择单位',
                        trigger: 'change',
                    },
                ],
                maturity: [
                    {
                        required: true,
                        message: '成熟度不能为空',
                        trigger: 'blur',
                    },
                ],
            },
            rulesForm: {},
            loading: false,
            fullscreen: false,
            templateVisible: false,
            tableHeight: '300',
        }
    },
    mounted() {
        //监听键盘按键事件
        let self = this
        window.onresize = function () {
            if (!self.checkFull()) {
                // 退出全屏后要执行的动作
                self.fullscreen = false
            }
        }
    },
    watch: {
         loadings:{
               handler(newVal,oldval){
                   this.loading=newVal
               },
               immediate:true
         },
        fullscreen(val) {
            if (val === true) {
                this.tableHeight = 'calc(100vh - 158px)'
            } else {
                this.tableHeight = '300'
            }
        },
        itemData: {
            handler(newVal) {
                if (newVal?.length) {

                    let extraData = [...newVal]
                    extraData.forEach((io) => {
                        io.rows = 1
                        if (io.lowerLimit === '' || io.lowerLimit === null) {
                            io.lowerLimit = undefined
                        }
                        if (io.upperLimit === '' || io.upperLimit === null) {
                            io.upperLimit = undefined
                        }
                        if (io.targetValue && io.targetValue.length > 0) {
                            io.rows = this.buildRows(io.targetValue)
                        }
                        if (io.detectionOne === '核对COA') {
                            io.checkoutType = '布尔型'
                        }
                        if (io.samplingOne === 'C=0') {
                            io.samplingTwo = undefined
                        }
                    })
                    this.formTable.extraList = JSON.parse(
                        JSON.stringify(extraData)
                    )
                } else {
                    let extraData =
                        this.extraList.length > 0
                            ? [...this.extraList]
                            : [
                                  {
                                      samplingOne: null,
                                      samplingTwo: null,
                                      samplingThree: null,
                                      measuringTool: null,
                                      inspectionType: '1',
                                      lowerLimit: null,
                                      upperLimit: null,
                                      specialCharacteristics: '0',
                                      projectCode: null,
                                      projectType: null,
                                      itemFrequency: '批',
                                      projectName: null,
                                      itemFrequencyValue: null,
                                      lowerLimitContains:"1",
                                        upperLimitContains:"1"
                                  },
                              ]
                    extraData.forEach((io) => {
                        if (io.lowerLimit === '' || io.lowerLimit === null) {
                            io.lowerLimit = undefined
                        }
                        if (io.upperLimit === '' || io.upperLimit === null) {
                            io.upperLimit = undefined
                        }
                        if (io.detectionOne === '核对COA') {
                            io.checkoutType = '布尔型'
                        }
                        if (io.samplingOne === 'C=0') {
                            io.samplingTwo = undefined
                        }
                    })
                    this.formTable.extraList = extraData
                    console.log('11111', this.formTable)
                }
                this.judgementTable()

            },
            deep: true,
            immediate: true,
        },
    },
    created() {
        // this.getProjectList()
        // this.getMaterialType()
        // this.getUnitList()
    },
    directives: {
        enterNumber: {
            inserted(el, binding, vnode, oldVnode) {
                el.addEventListener('keypress', function (e) {
                    e = e || window.event

                    let charcode =
                        typeof e.charCode === 'number' ? e.charCode : e.keyCode

                    let re = /^[0-9]\d*$/

                    if (
                        !re.test(String.fromCharCode(charcode)) &&
                        charcode > 9 &&
                        !e.ctrlKey
                    ) {
                        if (e.preventDefault) {
                            e.preventDefault()
                        } else {
                            e.returnValue = false
                        }
                    }
                })
            },
        },
    },
    methods: {
      // 下移行
      downRow(row, index) {
        let arr = this.formTable.extraList
        if(index >= arr.length-1){
          return
        }
        if (arr.length > 1 && index !== (arr.length - 1)) {
          this.swapItems(arr, index, index + 1)
        }
      },
      // 上移行
      upRow(row, index) {
        let arr = this.formTable.extraList
        if(index <= 0){
          return
        }
        if (arr.length > 1 && index !== 0) {
          this.swapItems(arr, index, index - 1)
        }

      },
      swapItems(arr, index1, index2){
        arr[index1] = arr.splice(index2,1,arr[index1])[0]
        return arr
      },
        checkoutTypeCopyFilter(row) {
            const current = this.dict.type.NYIQC_CHECK_TYPE.find((io) => {
                return io.value === row.checkoutTypeCopy
            })
            return current ? current.label : ''
        },
        formatCE_CLASS(e) {
            if (e) {
                let obj = this.dict.type.NYIQC_CE_CLASS.find((item) => {
                    return item.value === e
                })
                if (obj) {
                    return obj.label
                } else {
                    return ''
                }
            } else {
                return ''
            }
        },
        changeTestMethod(e, row, index) {
            if (row.detectionOne === '核对COA') {
                this.formTable.extraList[index].checkoutType = '布尔型'
            }
        },
        projectBlur(e, row, index) {
            console.log(e)
            console.log(row)
            if (row.clearInput) {
                this.formTable.extraList[index].projectName = null
            }
        },
        checkFull() {
            //判断浏览器是否处于全屏状态 （需要考虑兼容问题）
            //火狐浏览器
            var isFull =
                document.mozFullScreen ||
                document.fullScreen ||
                //谷歌浏览器及Webkit内核浏览器
                document.webkitIsFullScreen ||
                document.webkitRequestFullScreen ||
                document.mozRequestFullScreen ||
                document.msFullscreenEnabled
            if (isFull === undefined) {
                isFull = false
            }
            return isFull
        },

        changeFull() {
            const element = document.getElementById('fullscreen')
            if (this.fullscreen) {
                if (document.exitFullscreen) {
                    document.exitFullscreen()
                } else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen()
                } else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen()
                } else if (document.msExitFullscreen) {
                    document.msExitFullscreen()
                }
            } else {
                if (element.requestFullscreen) {
                    element.requestFullscreen()
                } else if (element.webkitRequestFullScreen) {
                    element.webkitRequestFullScreen()
                } else if (element.mozRequestFullScreen) {
                    element.mozRequestFullScreen()
                } else if (element.msRequestFullscreen) {
                    // IE11
                    element.msRequestFullscreen()
                }
            }
            this.fullscreen = !this.fullscreen
        },
        judgementTable() {
            this.formTable.extraList.forEach((io, index) => {
                io.index = index
            })
        },
        changeUpper(e, index) {
            console.log(e)
        },
        changeLower(e, index) {},
        textAreaChange(e, index) {
            const chinese = /[^\x00-\xff]/g
            let newVal = e.replace(chinese, '**')
            this.formTable.extraList[index].rows =
                newVal.length === 0 ? 1 : Math.ceil(newVal.length / 16)
            console.log(Math.ceil(newVal.length / 14))
        },
        upChange(e, index) {
            const reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/
            if (!reg.test(this.formTable.extraList[index].targetValue)) {
                return
            }
            this.formTable.extraList[index].upperLimit = parseFloat(
                (
                    parseFloat(e) +
                    parseFloat(this.formTable.extraList[index].targetValue)
                ).toFixed(4)
            )
        },
        lwChange(e, index) {
            const reg = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/
            if (!reg.test(this.formTable.extraList[index].targetValue)) {
                return
            }
            this.formTable.extraList[index].lowerLimit = parseFloat(
                (
                    parseFloat(this.formTable.extraList[index].targetValue) -
                    parseFloat(e)
                ).toFixed(4)
            )
        },
        buildRows(e) {
            const chinese = /[^\x00-\xff]/g
            let newVal = e.replace(chinese, '**')
            return Math.ceil(newVal.length / 16)
        },
        unitRemoteMethod(val, cb) {
            listCheckoutUnit({ unitName: val }).then((res) => {
                cb(res.rows)
            })
        },
        handleUnitSelect(e, scope) {
            this.formTable.extraList[scope.$index].unitName = e.unitName
            this.$forceUpdate()
        },
        projectRemoteMethod(val, cb, index) {
            listProject({ projectName: val }).then((res) => {
                if (res.rows.length === 0) {
                    this.formTable.extraList[index].clearInput = true
                } else {
                    this.formTable.extraList[index].clearInput = true
                }
                cb(res.rows)
            })
        },
        handleProjectSelect(e, scope) {
            // this.dialogForm.materialType = e
            this.formTable.extraList[scope.$index].projectCode = e.projectCode
            this.formTable.extraList[scope.$index].projectType = e.projectType
            this.formTable.extraList[scope.$index].projectId = e.projectId
            this.formTable.extraList[scope.$index].projectName = e.projectName
            this.$forceUpdate()
        },
        projectDataCallback(e, scope){
            this.formTable.extraList[scope.$index].projectCode = e.projectCode
            this.formTable.extraList[scope.$index].projectType = e.projectType
            this.formTable.extraList[scope.$index].projectId = e.projectId
            this.formTable.extraList[scope.$index].projectName = e.projectName
            this.$forceUpdate()
        },
        remarkRenderHeader(h, { column, $index }) {
            return h('span', [
                h(
                    'span',
                    {
                        style: {
                            color: '#ff1818',
                        },
                    },
                    '*'
                ),
                h('span', column.label),
            ])
        },
        projectNameRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        unitNameRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        itemFrequencyRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        itemFrequencyValueRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'blur',
                },
            ]
        },
        checkoutTypeRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        decimalPlaceRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'blur',
                },
            ]
        },
        upperLimitRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'blur',
                },
            ]
        },
        lowerLimitRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (parseInt(value) > parseInt(row.upperLimit)) {
                            return callback(new Error('下限值不能大于上限值!'))
                        }
                        callback()
                    },
                    trigger: 'blur',
                },
            ]
        },
        targetValueRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: ['blur', 'change'],
                },
            ]
        },
        samplingOneRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        samplingTwoRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: ['change', 'blur'],
                },
            ]
        },
        samplingThreeRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: ['change', 'blur'],
                },
            ]
        },
        detectionOneRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        detectionTwoRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: ['change'],
                },
            ]
        },
        symbolRules(row, index) {
            return [
                {
                    require: true,
                    validator: (rule, value, callback) => {
                        if (
                            value === null ||
                            value === undefined ||
                            value === ''
                        ) {
                            return callback(new Error(''))
                        }
                        callback()
                    },
                    trigger: 'change',
                },
            ]
        },
        getExtraInfo() {
            this.loading = true
            getExtraInfo(this.id).then((response) => {
                this.loading = false
                if (response.code == 200 && response.data) {
                    let data = response.data
                    data.lichn = data.lichn.substr(2)
                    data.lot = data.lot.substr(2)
                    this.viewModel = data
                    this.formTable.extraList = data.checkItemList
                }
            })
        },
        changeSampling(e, scope) {
            if (e == 'GB/T2828.1-2012') {
                this.formTable.extraList[scope.$index].samplingTwo =
                    this.dict.type.NYIQC_CE_CLASS[0].value
                this.formTable.extraList[scope.$index].samplingThree =
                    this.dict.type.NYIQC_CE_GB2828[0].value
            } else if (e == 'GB/T2828.2-2008') {
                this.formTable.extraList[scope.$index].samplingTwo =
                    this.dict.type.NYIQC_CE_CLASS[0].value
                this.formTable.extraList[scope.$index].samplingThree =
                    this.dict.type.NYIQC_CE_GB2828_2008[0].value
            } else if (e == 'C=0') {
                this.formTable.extraList[scope.$index].samplingThree =
                    this.dict.type.NYIQC_CE_C[0].value
                this.formTable.extraList[scope.$index].samplingTwo = undefined
            } else {
                this.formTable.extraList[scope.$index].samplingTwo = null
                this.formTable.extraList[scope.$index].samplingThree = null
            }
        },
        getUnitList() {
            listCheckoutUnit().then((res) => {
                this.unitList = res.rows
            })
        },
        changeProject(e) {
            let obj = this.projectList.find((item) => {
                return item.projectName === e.row.projectName
            })
            this.formTable.extraList[e.$index].projectCode = obj.projectCode
            this.formTable.extraList[e.$index].projectType = obj.projectType
            this.formTable.extraList[e.$index].projectId = obj.projectId
        },
        getProjectList() {
            listProject().then((res) => {
                this.projectList = res.rows
            })
        },
        getMaterialType() {
            // listALLMaterialType().then((res) => {
            //     this.materialOptions = res.data
            // })
        },
        checkoutTypeChange(row) {
            let data = this.checkoutTypeCopyFilter(row)
            row.checkoutTypeCopy.includes('boole')
                ? (row.checkoutType = '布尔型')
                : (row.checkoutType = '数值')
            row.checkoutTypeCopy = data
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.formTable.extraList.push({ ...this.extraList })
            this.judgementTable()
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            let selectIndex = selection.map((item) => item.index)
            this.formTable.extraList.forEach((io, index) => {
                if (selectIndex.includes(io.index)) {
                    io.isHighLight = true
                } else {
                    io.isHighLight = false
                }
            })
            this.single = selection.length != 1
            this.multiple = !selection.length
        },
        tableRowClassName({ row, rowIndex }) {

            if (row.isHighLight === true) {
                console.log('rowIndex', row)
                return 'rowHighLight' //若isHighLight为true，则使用“rowHighLight”样式
            } else {
                return ''
            }
        },

        /** 发起检验提交 */
        submitAddForm: function () {
            if (this.disabled) {
                this.$emit('callback', this.formTable.extraList)
            } else {
                this.$refs['formTable'].validate((val, error, three) => {
                    console.log(this.$refs['formTable'].fields)
                    if (val) {
                        this.$emit('callback', this.formTable.extraList)
                    } else {
                        let validateMessage = ''
                        this.$refs['formTable'].fields.forEach((io) => {
                            if (
                                io.validateMessage &&
                                io.validateMessage.length > 0
                            ) {
                                validateMessage = io.validateMessage
                            }
                        })
                        if (validateMessage.length > 0) {
                            this.$modal.msgError(validateMessage)
                        } else {
                            this.$modal.msgError('检验项信息填写不完整，请仔细检查后再确定!')
                        }
                    }
                })
            }
        },
        detectCallback(val, row, index) {
            console.log(val)
            this.$set(this.formTable.extraList[index], 'detectionTwo', val)
            this.$refs.formTable.validateField(
                'extraList.' + index + '.detectionTwo'
            )
        },
        /** 删除按钮操作 */
        handleDelete(row) {
            if (this.formTable.extraList.length === 1) {
                this.$modal.msgWarning('请至少保留一条检验项!')
                return
            }
            this.formTable.extraList.splice(row.$index, 1)
            this.judgementTable()
        },
        /** 删除按钮操作 */
        handleViewDelete(row) {
            this.formTable.extraList.splice(row.$index, 1)
            this.judgementTable()
        },
        handleSelectTemplate() {
            this.templateVisible = true
        },
        templateDataCallback(data) {
            console.log('检验标准选择模板：', data)
            let extraData = [...data.itemList]
            // extraData.forEach((io) => {
            //     io.rows = 1
            //     if (io.lowerLimit === '' || io.lowerLimit === null) {
            //         io.lowerLimit = undefined
            //     }
            //     if (io.upperLimit === '' || io.upperLimit === null) {
            //         io.upperLimit = undefined
            //     }
            //     if (io.targetValue && io.targetValue.length > 0) {
            //         io.rows = this.buildRows(io.targetValue)
            //     }
            //     if (io.detectionOne === '核对COA') {
            //         io.checkoutType = '布尔型'
            //     }
            // })
            this.formTable.extraList = extraData
            this.judgementTable()
        },
        mToolCallback(rows, scope) {
            console.log('mToolCallback', rows)
            this.formTable.extraList[scope.$index].measuringCode = rows
        },
    },
}
</script>
<style lang="scss" scoped>
::v-deep .el-card {
    padding-top: 0px !important;
    border: 0px;
    box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    padding-bottom: 20px;
}
::v-deep .app-container {
    padding: 0px !important;
}
::v-deep .el-aside {
    padding: 0;
    margin-bottom: 0;
}

.container-header {
    float: left;
    width: 100%;
    border-bottom: 1px solid #ededf2;
    padding-left: 12px;
}
.container-table {
    float: left;
    margin-top: 6px;
    width: 100%;
}
.header-left {
    float: left;
    font-size: 14px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #333333;
    line-height: 40px;
}
.header-right {
    float: right;
}
.hign-line {
    position: relative;
    left: -8px;
    top: 14px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #0b7be3;
    float: left;
}
.mb8 {
    float: left;
    margin-top: 6px;
    width: 100%;
}

::v-deep .el-card {
    padding-top: 0px;
}

::v-deep .el-table .el-form-item {
    margin-bottom: 0;
}
::v-deep .el-input-group {
    vertical-align: baseline;
}
::v-deep .multipleInput .cell {
    display: flex;
}
::v-deep input::-webkit-outer-spin-button,
::v-deep input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
}
::v-deep input[type='number'] {
    -moz-appearance: textfield !important;
}
// ::v-deep .el-table__body {
//     height: 100% !important;
// }
::v-deep .el-textarea__inner {
    min-height: 28px !important;
    padding: 3px 15px;
}
.textarea-change ::v-deep .el-form-item__content {
    line-height: 30px !important;
}
::v-deep .rowHighLight {
    background: oldlace;
}
::v-deep .view-textarea .el-textarea__inner {
    padding-left: 0px;
    border: 0px !important;
    background: transparent;
}
::v-deep .el-table__body-wrapper {
    z-index: 2;
}
</style>
